<!-- 温州二中 衢州二中 沈文轩等人版权所有 -->
<!--suppress HtmlDeprecatedAttribute, HtmlUnknownTarget -->
<head>
    <meta charset="utf-8">
    <title>已发布的题目</title>

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->
    <!-- <link href="{{url_for('static',filename='css/tabler.min.css')}}" rel="stylesheet"> -->
    <link href="{{ url_for('static',filename='css/docs.css') }}" rel="stylesheet">

    <link href="{{ url_for('static',filename='css/bootstrap.min.css') }}" rel="stylesheet">


    <script src="{{ url_for('static',filename='js/chart.js') }}"></script>
    <script src="{{ url_for('static',filename='js/bootstrap.bundle.min.js') }}"></script>
    <script src="{{ url_for('static',filename='js/crypto-js.min.js') }}"></script>
    <script src="{{ url_for('static',filename='js/jquery-1.12.4.min.js') }}"></script>
    <link rel="icon" href="{{ url_for('static',filename='images/ico/favicon2.ico') }}">
    <script src="{{ url_for('static',filename='js/sweetalert2.all.min.js') }}"></script>
    <link href="/static/css/sweetalert2.min.css" rel="stylesheet">
    <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <div class="container-fluid">
        <a class="navbar-brand">
            <img src="{{ url_for('static',filename='images/ico/favicon2.ico') }}" alt="" width="30" height="24">
            {{ Name }}欢迎浏览 学生答题情况面板！
        </a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
                aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="system">主页</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link active" href="class">课程管理</a>
                </li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
                       data-bs-toggle="dropdown" aria-expanded="false">
                        查看数据
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <li>
                            <a class="dropdown-item" href="/StuEXD">学生答题情况</a>
                        </li>
                        <li>
                            <a class="dropdown-item" href="/StuCdt">学生上课情况</a>
                        </li>
                        <li>
                            <a class="dropdown-item disabled" href="/all_timu">->已发布的题目</a>
                        </li>
                    </ul>
                </li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
                       data-bs-toggle="dropdown"
                       aria-expanded="false">
                        账号管理
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <li><a class="dropdown-item disabled">用户名：admin</a></li>
                        <li>
                            <hr class="dropdown-divider">
                        </li>
                        <li>
                            <a class="dropdown-item" href="account_management">账户设置</a>
                        </li>
                        <li>
                            <a class="dropdown-item" href="systemlogout">登出</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>
<div class="card">
    <div class="card-header" align="center">
        学生答题数据显示
    </div>
    <div class="card-body">
        <table class="table table-striped align-self-center overflow-x-auto">
            <thead>
            <tr>
                <th>题目编号</th>
                <th>题目</th>
                <th>A选项</th>
                <th>B选项</th>
                <th>C选项</th>
                <th>D选项</th>
                <th>答案</th>
            </tr>
            </thead>
            <tbody>
            {% for i in range(data|length) %}
                <tr>
                    {% for j in range(data[i]|length) %}
                        <td>{{ data[i][j] }}</td>
                    {% endfor %}
                </tr>
            {% endfor %}
            </tbody>
        </table>
        <div align="center">
            <button class="btn btn-primary" onclick="refresh()">刷新数据</button>
            <button class="btn btn-danger" onclick="clear_data()">清空历史记录</button>
        </div>
    </div>
</div>
</body>
<script>
    function refresh() {
        window.location.reload();
    }

    function clear_data() {
        swal({
            title: "警告",
            text: "历史数据一旦删除，无法恢复",
            icon: "warning",
            buttons: true,
            dangerMode: true,
        })
            .then((willDelete) => {
                if (willDelete) {
                    const xhr = new XMLHttpRequest();
                    xhr.open('POST', '/all_timu', true);
                    xhr.setRequestHeader('Content-Type', 'application/json');
                    xhr.send();

                    //接受
                    xhr.onreadystatechange = function () {
                        if (xhr.readyState === XMLHttpRequest.DONE) {
                            if (xhr.responseText === 'success') {
                                swal("删除成功", {
                                    icon: "success",
                                }).then((_) => {
                                    refresh();
                                })
                            } else {
                                Swal.fire('未知错误', '', 'error')
                            }
                        }
                    }
                }
            });
    }
</script>